package com.wk.springboot.bean;

import com.wk.springboot.contants.ExportCont;
import org.apache.commons.lang.StringUtils;

import java.util.List;

/**
 * @author changleying
 * @date 2017-5-23
 */
public class ExportEntity {
    private String SOURCE_TABLE;

    private String TARGET_TABLE;


    private String PYTHONMETHOD;

    private String delNull;
    private String fallbackClassName;
    private String columns;
    private List<field> field;
    private List<target> TARGET;
    private List<param> param;
    private String extract;
    private String muli_node = ";";

    private String concurrent = "5";

    private String splitcolumn;

    private String distinct;

    //忽略
    private Integer dataNum;

    /**
     * 指定的结果集(字符串定义‘,’分割), ETL会做一次额外处理(目前用于处理 ES 的查询结果, 可获取 _id, _score, _source 等索引级别明细字段);
     * 不指定按照原操作执行 (只出query 中 _source.include 或 field枚举 的字段)
     */
    private String results;
    //调用外部脚本方法名称
    private String scriptmethod;

    public String getScriptmethod() {
        return scriptmethod;
    }

    public void setScriptmethod(String scriptmethod) {
        this.scriptmethod = scriptmethod;
    }

    public String getResults() {
        return results;
    }

    public void setResults(String results) {
        this.results = results;
    }

    public String getColumns() {
        return columns;
    }

    public String getExtract() {
        return extract;
    }

    public String getMuli_node() {
        return muli_node;
    }

    public void setMuli_node(String muli_node) {
        this.muli_node = muli_node;
    }

    public void setExtract(String extract) {
        this.extract = extract;
    }

    public void setColumns(String columns) {
        this.columns = columns;
    }

    public String getFallbackClassName() {
        return fallbackClassName;
    }

    public List<ExportEntity.field> getField() {
        return field;
    }

    public void setField(List<ExportEntity.field> field) {
        this.field = field;
    }

    public List<ExportEntity.param> getParam() {
        return param;
    }

    public void setParam(List<ExportEntity.param> param) {
        this.param = param;
    }

    public void setFallbackClassName(String fallbackClassName) {
        this.fallbackClassName = fallbackClassName;
    }


    public List<ExportEntity.target> getTARGET() {
        return TARGET;
    }

    public void setTARGET(List<ExportEntity.target> target) {
        this.TARGET = target;
    }

    public List<field> getfield() {
        return field;
    }

    public void setfield(List<field> field) {
        this.field = field;
    }

    public String getSOURCE_TABLE() {
        return SOURCE_TABLE;
    }

    public void setSOURCE_TABLE(String source_table) {
        this.SOURCE_TABLE = source_table;
    }

    public String getTARGET_TABLE() {
        return TARGET_TABLE;
    }

    public void setTARGET_TABLE(String target_table) {
        this.TARGET_TABLE = target_table;
    }

    public Integer getDataNum() {
        return dataNum;
    }

    public void setDataNum(Integer dataNum) {
        this.dataNum = dataNum;
    }

    public String getDistinct() {
        return distinct;
    }

    public void setDistinct(String distinct) {
        this.distinct = distinct;
    }

    public String getConcurrent() {
        return concurrent;
    }

    public void setConcurrent(String concurrent) {
        this.concurrent = concurrent;
    }

    public String getSplitcolumn() {
        return splitcolumn;
    }

    public void setSplitcolumn(String splitcolumn) {
        this.splitcolumn = splitcolumn;
    }

    public String getPYTHONMETHOD() {
        return PYTHONMETHOD;
    }

    public void setPYTHONMETHOD(String PYTHONMETHOD) {
/*        if (StringUtils.isNotEmpty(PYTHONMETHOD) && PYTHONMETHOD.startsWith("/")) {
            this.PYTHONMETHOD = ExportCont.path + "/" + ExportCont.TASKS_DIRECTORY + PYTHONMETHOD;
        } else if (StringUtils.isNotEmpty(PYTHONMETHOD)){
            this.PYTHONMETHOD = ExportCont.path + "/" + ExportCont.TASKS_DIRECTORY + "/" + PYTHONMETHOD;
        }else{
            this.PYTHONMETHOD = null;
        }*/
    }

    public String getDelNull() {
        if (delNull == null) {
            return "1";
        }
        return delNull;
    }

    public void setDelNull(String delNull) {
        this.delNull = delNull;
    }

    @Override
    public String toString() {
        return "ExportEntity [source_table=" + SOURCE_TABLE + ", target_table=" + TARGET_TABLE + ", field=" + field + ", distinct="
                + distinct + ", dataNum=" + dataNum + "]";
    }

    public static class target {
        private String node;
        private String name;
        private String primarykey;
        private String column;

        public String getNode() {
            return node;
        }

        public void setNode(String node) {
            this.node = node;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPrimarykey() {
            return primarykey;
        }

        public void setPrimarykey(String primarykey) {
            this.primarykey = primarykey;
        }

        public String getColumn() {
            return column;
        }

        public void setColumn(String column) {
            this.column = column;
        }
    }

    public static class param {
        private String name;
        private String value;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }

    public static class field {
        private String name;

        private String method;

        private String relationName;

        private String mappingName;

        /**
         * 以下是为minio采集添加的属性
         */
        private String targetPath;

        private String fileName;

        private String fileExt;

        private String decodeType;

        private String encoding;

        /**
         *
         */
        public field() {
        }

        public String getname() {
            return name;
        }

        public void setname(String name) {
            this.name = name;
        }

        public String getmethod() {
            return method;
        }

        public void setmethod(String method) {
            this.method = method;
        }

        public String getrelationName() {
            return relationName;
        }

        //n_prename1,n_prename2=2;3
        public void setrelationName(String relationName) {
            this.relationName = relationName;
        }

        public String getmappingName() {
            return mappingName;
        }

        public void setmappingName(String mappingName) {
            this.mappingName = mappingName;
        }

        /*public String getMappingName() {
            return mappingName;
        }

        public void setMappingName(String mappingName) {
            this.mappingName = mappingName;
        }*/

        public String gettargetPath() {
            return targetPath;
        }

        public void settargetPath(String targetPath) {
            this.targetPath = targetPath;
        }

        public String getfileName() {
            return fileName;
        }

        public void setfileName(String fileName) {
            this.fileName = fileName;
        }

        public String getfileExt() {
            return fileExt;
        }

        public void setfileExt(String fileExt) {
            this.fileExt = fileExt;
        }

        public String getdecodeType() {
            return decodeType;
        }

        public void setdecodeType(String decodeType) {
            this.decodeType = decodeType;
        }

        public String getencoding() {
            return encoding;
        }

        public void setencoding(String encoding) {
            this.encoding = encoding;
        }


        @Override
        public String toString() {
            return "field [name=" + name + ", method=" + method + ", relationName=" + relationName + ", mappingName=" + mappingName + "]";
        }

    }
}
